//
//  ProfileViewController.m
//  Behinders
//
//  Created by sigure on 14-10-23.
//  Copyright (c) 2014年 sigure. All rights reserved.
//

#import "ProfileViewController.h"
#import "AppDelegate.h"
#import "VPViewController.h"



@interface ProfileViewController ()






@end

@implementation ProfileViewController

- (void)viewDidLoad {
    //int mainHeight = [UIScreen mainScreen].bounds.size.height;
    int mainWidth = [UIScreen mainScreen].bounds.size.width;
    UITabBar *bar = [[UITabBar alloc]initWithFrame:CGRectMake(0,0,mainWidth,20)];
    UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(60, 100, 60, 20)];
    UILabel *password = [[UILabel alloc]initWithFrame:CGRectMake(60, 140, 60, 20)];
    UILabel *lostpassword =[[UILabel alloc]initWithFrame:CGRectMake(60,210,100,20)];
    UILabel *reg = [[UILabel alloc]initWithFrame:CGRectMake(260,210,80,20)];
    UITextField *name2 = [[UITextField alloc]initWithFrame:CGRectMake(120, 100, 180, 20)];
    UITextField *password2 = [[UITextField alloc]initWithFrame:CGRectMake(120, 140, 180, 20)];
    [name2 setTag:101];
    [password2 setTag:102];
    UIButton *leftbutton =[[UIButton alloc]initWithFrame:CGRectMake(20, 20, 40, 20)];
    UIButton *button =[[UIButton alloc]initWithFrame:CGRectMake(60, 180, 240, 30)];
    name2.keyboardType = UIKeyboardTypeNumberPad;
    name2.borderStyle = UITextBorderStyleLine;
    name2.returnKeyType =UIReturnKeyNext;
    password2.borderStyle = UITextBorderStyleLine;
    [password2 setSecureTextEntry:YES];
    name.text = @"手机号:";
    password.text =@"密码:";
    lostpassword.text =@"找回密码";
    reg.text =@"注册";
    [button setTitle:@"登陆" forState:UIControlStateNormal];
    [leftbutton setTitle:@"返回" forState:UIControlStateNormal];
    [leftbutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.backgroundColor = [UIColor grayColor];
    button.showsTouchWhenHighlighted = YES;
    [button addTarget:self action:@selector(butClick) forControlEvents:UIControlEventTouchUpInside];
    password2.borderStyle = UITextBorderStyleRoundedRect;
    name2.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:bar];
    [self.view addSubview:name];
    [self.view addSubview:password];
    [self.view addSubview:lostpassword];
    [self.view addSubview:reg];
    [self.view addSubview:name2];
    [self.view addSubview:password2];
    [self.view addSubview:button];
    [self.view addSubview:leftbutton];
    
    
    
    
    
    [super viewDidLoad];
    
    // Do any additional setup after loading the view.
}

-(void) butClick {
    UITextField *textfield=(UITextField *)[self.view viewWithTag:101];
    NSString *phone = textfield.text;
    UITextField *textfield2=(UITextField *)[self.view viewWithTag:102];
    NSString *password = textfield2.text;
    if ([phone length] == 0)
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"用户名不能为空!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    }
    else if([password length] == 0)
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"密码不能为空！" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    }
    else if([phone isEqual:@"1"] && [password isEqual:@"2"])
    {
        NSLog(@"%@",password);
        AppDelegate *myDelegate = [[UIApplication sharedApplication] delegate];
        myDelegate.isLogin = YES;
        VPViewController *vp = [[VPViewController alloc]init];
        [self.navigationController pushViewController:vp animated:YES];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"用户名或密码错误!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
